#include <cstdio>
#include <cstring>

int main(void) {
	int man, die, last_remain;
	
	//man = 30, die = 9, last_remain = 15;
	printf("输入总人数，第几个人死， 剩余多少人时停止：");
	scanf("%d%d%d", &man, &die, &last_remain);

	bool a[man+1];
	memset(a, true, sizeof(a));

	int remain = man;
	int count = 1;
	int circle = 1;;
	while(remain > last_remain) {
		// 
		printf("第%d轮死的人: ", circle);
		for(int i=1; i<=man; i++) {
			if(a[i]) {
				if(count == die) {
					printf("%d ", i);
					remain--;
					count = 0;
					a[i] = false;
				}
				count++;
			}
		}
		printf("\n");

		circle++;
	}

	for(int i=1; i<=man; i++) {
		if(a[i]) {
			printf("%d\n", i);
		}
	}

	return 0;
}
